/*
 * ds18b20.h
 *
 *  Created on: 21/01/2015
 *      Author: santiago
 */

#ifndef DS18B20_H_
#define DS18B20_H_

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <inc/lm4f120h5qr.h>
#include <driverlib/rom.h>
#include <inc/hw_memmap.h>
#include <inc/hw_types.h>
#include <inc/hw_memmap.h>
#include <inc/hw_gpio.h>
#include <inc/hw_ints.h>
#include <inc/hw_memmap.h>
#include <inc/hw_types.h>
#include <driverlib/debug.h>
#include <driverlib/fpu.h>
#include <driverlib/gpio.h>
#include <driverlib/interrupt.h>
#include <driverlib/pin_map.h>
#include <driverlib/sysctl.h>
#include <driverlib/timer.h>
#include "../gdefines.h"
#include "onewire.h"


typedef struct ds1820SPad{
	int16_t temperatura;
	uint8_t thuserb1;
	uint8_t thuserb2;
	uint8_t config;
	uint8_t res[3];
	uint8_t crc;
}ds18b20SPad_t;

typedef struct ds1820rawSPad{
	uint8_t bytes[8];
}ds18b20rawSPad_t;

typedef union ds18b20sp{
	ds18b20rawSPad_t raw;
	ds18b20SPad_t	spad;
} ds18b20SP_u;


/**
 * Prototipos de funciones
 */

error_t ds18b20_getTemp(owDevice_t * sensor, int16_t *temperatura);

error_t ds18b20_Convert(void);
error_t ds18b20_setCfg(owDevice_t *sensor, uint8_t *datos);

#endif /* DS18B20_H_ */
